package mspbots.hubspot.data.core.contacts;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import mspbots.hubspot.data.core.properties.PropertiesRepository;
import mspbots.hubspot.data.core.properties.Property;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;

import java.util.List;

/**
 * data.connector.hubspot.core.contacts.ContactService
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2020/3/31
 */
@Log4j2
@Service
@RequiredArgsConstructor
public class ContactsServiceImpl {

    private final ContactsRepository contactsRepository;
    private final PropertiesRepository propertiesRepository;

    public Flux<Contact> search(Long tenantId, List<String> emails) {
        log.info("Find by tenantId [{}],emails {}", tenantId, emails);
        return this.contactsRepository.findByEmails(tenantId, emails);
    }

    public Flux<Property> properties(Long tenantId) {
        return this.propertiesRepository.findByTenantIdAndType(tenantId, "Contacts");
    }

}
